/***************************************************************************
                          MyException.hpp  -  description
                             -------------------
    begin                : October 29 2009
    copyright            : Copyright 2009, ACKERMANN Thibaut
    email                : tackerma@edu.univ-fcomte.fr
    website              : http://code.google.com/p/nover-project/
    license              : GNU GPL v3
 ***************************************************************************/
/* *************************************************************************
 *  This file is part of NOver-Project.
 *  
 *  NOver-Project is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  NOver-Project is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with NOver-Project.  If not, see <http://www.gnu.org/licenses/>.
 * *************************************************************************/


#ifndef _MYEXCEPTION_
#define _MYEXCEPTION_

#include <exception>
#include <string>
#include <sstream>


// TODO : voir si l'utilisation d'un string ne dérange pas.
// (probleme si on utilise cette classe après un bad_alloc)
// TODO : eventuellement renommer (nom trop pourri)
/**
 * La classe MyException définit une exception qui affiche un message
 * @author Thibaut Ackermann
 */
class MyException : public std::exception
{
public:
	
	MyException(std::string txt, std::string file, int line)
	{
		msg = txt;
		msg += " (";
		msg += file;
		msg += ":";
		
		std::stringstream conv;
		conv << line;
		
		msg += conv.str();
		msg += ")\n";
	}
	
	virtual ~MyException() throw()
	{
	}
	
	virtual const char* what() const throw()
	{
		return msg.c_str();
	}
	
private:
	
	std::string msg;
	
};

#endif

